<!DOCTYPE html>

<html>
    <head>
        <meta charset=UTF-8 />
        <title>AvatarMonster Sample | TM Life</title>
        <style>
            * {
                margin: 0;
                padding: 0;
            }
        </style>
        <script src="lib/enchant.js/enchant.js"></script>
        <script src="lib/enchant.js/plugins/avatar.enchant.js"></script>
        <script>
            enchant();
            
            // リソース
            var IMAGE_PATH          = "lib/enchant.js/images/";
            var MONSTER1_IMAGE      = IMAGE_PATH + "monster/monster1.gif";
            var MONSTER2_IMAGE      = IMAGE_PATH + "monster/monster2.gif";
            var MONSTER3_IMAGE      = IMAGE_PATH + "monster/monster3.gif";
            var MONSTER4_IMAGE      = IMAGE_PATH + "monster/monster4.gif";
            var MONSTER5_IMAGE      = IMAGE_PATH + "monster/monster5.gif";
            var MONSTER6_IMAGE      = IMAGE_PATH + "monster/monster6.gif";
            var MONSTER7_IMAGE      = IMAGE_PATH + "monster/monster7.gif";
            var BIG_MONSTER1_IMAGE  = IMAGE_PATH + "monster/bigmonster1.gif";
            var BIG_MONSTER2_IMAGE  = IMAGE_PATH + "monster/bigmonster2.gif";
            
            var RESOURCE = [
                MONSTER1_IMAGE,
                MONSTER2_IMAGE,
                MONSTER3_IMAGE,
                MONSTER4_IMAGE,
                MONSTER5_IMAGE,
                MONSTER6_IMAGE,
                MONSTER7_IMAGE,
                BIG_MONSTER1_IMAGE,
                BIG_MONSTER2_IMAGE,
            ];
            
            window.onload = function() {
                var monsterImage = document.location.search.substr(1);  // クエリで使用するモンスター画像を指定
                if (!monsterImage) monsterImage = "BIG_MONSTER1_IMAGE";
                
                // ゲームクラス生成
                var game = new Game();
                game.preload(RESOURCE);
                
                // 初期化
                game.onload = function() {
                    var scene = game.rootScene;
                    scene.backgroundColor = "#aaa";
                    
                    // AvatarMonster
                    var image = game.assets[ window[monsterImage] ];    // 使用する画像を取得
                    var monster = new AvatarMonster( image );           // 画像を渡してAvatarMonsterを生成
                    scene.addChild(monster);                            // シーンに追加
                    monster.moveTo(20, 20);                             // いい感じに移動
                };
                
                game.start();
            };
        </script>
    </head>
    <body>
        
    </body>
</html>